package com.ruoyi.web.controller.business;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.yanjing.domain.PersonnelCertificates;
import com.ruoyi.yanjing.service.IPersonnelCertificatesService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 人员证件信息Controller
 * 
 * @author whz
 * @date 2024-12-04
 */
@RestController
@RequestMapping("/yanjing/certificates")
public class PersonnelCertificatesController extends BaseController
{
    @Autowired
    private IPersonnelCertificatesService personnelCertificatesService;

    /**
     * 查询人员证件信息列表
     */
    @PreAuthorize("@ss.hasPermi('yanjing:certificates:list')")
    @GetMapping("/list")
    public TableDataInfo list(PersonnelCertificates personnelCertificates)
    {
        startPage();
        List<PersonnelCertificates> list = personnelCertificatesService.selectPersonnelCertificatesList(personnelCertificates);
        return getDataTable(list);
    }

    /**
     * 导出人员证件信息列表
     */
    @PreAuthorize("@ss.hasPermi('yanjing:certificates:export')")
    @Log(title = "人员证件信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PersonnelCertificates personnelCertificates)
    {
        List<PersonnelCertificates> list = personnelCertificatesService.selectPersonnelCertificatesList(personnelCertificates);
        ExcelUtil<PersonnelCertificates> util = new ExcelUtil<PersonnelCertificates>(PersonnelCertificates.class);
        util.exportExcel(response, list, "人员证件信息数据");
    }

    /**
     * 获取人员证件信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('yanjing:certificates:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(personnelCertificatesService.selectPersonnelCertificatesById(id));
    }

    /**
     * 新增人员证件信息
     */
    @PreAuthorize("@ss.hasPermi('yanjing:certificates:add')")
    @Log(title = "人员证件信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PersonnelCertificates personnelCertificates)
    {
        return toAjax(personnelCertificatesService.insertPersonnelCertificates(personnelCertificates));
    }

    /**
     * 修改人员证件信息
     */
    @PreAuthorize("@ss.hasPermi('yanjing:certificates:edit')")
    @Log(title = "人员证件信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PersonnelCertificates personnelCertificates)
    {
        return toAjax(personnelCertificatesService.updatePersonnelCertificates(personnelCertificates));
    }

    /**
     * 删除人员证件信息
     */
    @PreAuthorize("@ss.hasPermi('yanjing:certificates:remove')")
    @Log(title = "人员证件信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(personnelCertificatesService.deletePersonnelCertificatesByIds(ids));
    }
}
